package one.stand.controller;

import one.stand.model.ResultModel;
import one.stand.request.CompanyAccountRequest;
import one.stand.request.OrdersRequest;
import one.stand.response.OrdersResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 订单信息
 * @author
 */
@RestController
@RequestMapping("/orders")
public class OrdersController extends BaseController {

    /**
     * 根据公司查询订单("订单状态（1待付款，2待发货，3待收货，4已完成，5交易取消，6退款成功）")
     */
    @PostMapping("/selectOrdersInfo")
    public ResultModel selectOrdersInfo(@RequestBody OrdersRequest request) {
        return ordersService.selectOrdersInfo(request);
    }

    /**
     * 根据公司查询订单("订单状态（1待付款，2待发货，3待收货，4已完成，5交易取消，6退款成功）") PC端
     */
    @PostMapping("/selectOrdersInfoPc")
    public ResultModel<Map<String, Object>> selectOrdersInfoPc(@RequestBody OrdersRequest request) {
        return ordersService.selectOrdersInfoPc(request);
    }

    /**
     * 查询订单详情
     */
    @PostMapping("/getOrdersInfo")
    public ResultModel<List<OrdersResponse>> getOrdersInfo(@RequestBody OrdersRequest request) {
        return ordersService.getOrdersInfo(request);
    }

    /**
     * 修改订单状态("订单状态（1待付款，2待发货，3待收货，4已完成，5交易取消，6退款成功）")
     * 撤销订单，确认发货
     */
    @PostMapping("/updateOrderState")
    public ResultModel updateOrderState(@RequestBody OrdersRequest request) {
        return ordersService.updateOrderState(request);
    }

    /**
     * 修改订单退款状态1未申请，2退款申请中，3退款成功
     */
    @PostMapping("/updateRefundState")
    public ResultModel updateRefundState(@RequestBody OrdersRequest request) {
        return ordersService.updateRefundState(request);
    }

    /**
     * 退款（回调）
     */
    @PostMapping("/backRefund")
    public String backRefund(@RequestParam(value="request") String request){
        return ordersService.backRefund(request);
    }

    /**
     * 删除已过期的订单信息
     */
    @PostMapping("/delOrders")
    public ResultModel delOrders(@RequestBody OrdersRequest request){
        return ordersService.delOrders(request);
    }
}
